package com.itheima03;

import Utils.DataSourceUtils;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Properties;

public class UtilsTest {
        public static void main(String[] args) throws Exception {
            Properties properties = null;
            //获取配置文件的流对象
            DataSource dataSource1 = DataSourceUtils.getDataSource();
            Connection con = DataSourceUtils.getConnection();
            PreparedStatement statement1 = con.prepareStatement("SELECT * from Student;");
            ResultSet resultSet = statement1.executeQuery();
            while(resultSet.next()){
                System.out.println(resultSet.getInt("sid") + "\t" + resultSet.getString("name") + "\t" + resultSet.getInt("age") + "\t" + resultSet.getDate("birthday"));
            }
            //6.释放资源
            DataSourceUtils.close(con,resultSet,statement1);
        }
    }


